package com.example.recuitactivity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.recuitactivity.bean.Interview;
import com.example.recuitactivity.helper.DbOpenHelper;

public class InterviewNotifyActivity extends AppCompatActivity {
    private TextView tv_name,tv_sex,tv_company,tv_post,tv_date,tv_tips,tv_company2;
    private DbOpenHelper dbOpenHelper;

    public void initUI(){
        tv_name=(TextView) findViewById(R.id.tv_interview_notify_detail_name);
        tv_sex=(TextView) findViewById(R.id.tv_interview_notify_detail_sex);
        tv_company=(TextView) findViewById(R.id.tv_interview_notify_detail_company);
        tv_post=(TextView) findViewById(R.id.tv_interview_notify_detail_post);
        tv_date=(TextView) findViewById(R.id.tv_interview_notify_detail_date);
        tv_tips=(TextView) findViewById(R.id.tv_interview_notify_detail_tips);
        tv_company2=(TextView) findViewById(R.id.tv_interview_notify_detail_company2);
    }

    public void initDatas(){
        dbOpenHelper=new DbOpenHelper(this);
        long interview_id=getIntent().getExtras().getLong("interview_id");
        Interview interview=dbOpenHelper.getInterviewById(interview_id);
        tv_name.setText(interview.getCandidate());
        String sex=dbOpenHelper.getCandidateSexById(interview.getCid());
        tv_sex.setText(sex.equals("男")?"先生":"女士");
        tv_company.setText(interview.getEnterprise());
        tv_company2.setText(interview.getEnterprise());
        tv_post.setText(interview.getPost());
        tv_date.setText(interview.getInterviewDate());
        tv_tips.setText(interview.getInterviewTips());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_interview_notify);
        ActionBar actionBar=getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        initUI();
        initDatas();
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if(item.getItemId()==android.R.id.home){
            finish();
            return true;
        }
        return false;
    }

}